|
1
|
|
|
/** |
|
2
|
|
|
* (c) Kitodo. Key to digital objects e.V. <[email protected]> |
|
3
|
|
|
* |
|
4
|
|
|
* This file is part of the Kitodo and TYPO3 projects. |
|
5
|
|
|
* |
|
6
|
|
|
* @license GNU General Public License version 3 or later. |
|
7
|
|
|
* For the full copyright and license information, please read the |
|
8
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* @return {number|undefined} |
|
13
|
|
|
*/ |
|
14
|
|
|
ol.Map.prototype.getZoom = function(){ |
|
|
|
|
|
|
15
|
|
|
return this.getView().getZoom(); |
|
16
|
|
|
}; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Returns an array containing the min and max zoom level [minZoom, maxZoom] |
|
20
|
|
|
* @return {Array.<number>} |
|
21
|
|
|
*/ |
|
22
|
|
|
ol.Map.prototype.getZoomRange = function() { |
|
|
|
|
|
|
23
|
|
|
var maxZoom = window.OL3_MAX_ZOOM !== undefined && !isNaN(window.OL3_MAX_ZOOM) ? window.OL3_MAX_ZOOM : 18; |
|
24
|
|
|
return [0, maxZoom]; |
|
25
|
|
|
}; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Zooms to given zoomLevel |
|
29
|
|
|
* |
|
30
|
|
|
* @param {number} zoomLevel |
|
31
|
|
|
*/ |
|
32
|
|
|
ol.Map.prototype.zoom = function(zoomLevel) { |
|
|
|
|
|
|
33
|
|
|
var view = this.getView(), |
|
34
|
|
|
resolution = view.getResolution(); |
|
35
|
|
|
this.beforeRender(ol.animation.zoom({ |
|
|
|
|
|
|
36
|
|
|
'resolution': resolution, |
|
37
|
|
|
'duration': 500 |
|
38
|
|
|
})); |
|
39
|
|
|
view.setZoom(zoomLevel); |
|
40
|
|
|
}; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Zooms in the map. Uses ol.animation for smooth zooming |
|
44
|
|
|
*/ |
|
45
|
|
|
ol.Map.prototype.zoomIn = function() { |
|
46
|
|
|
var view = this.getView(), |
|
47
|
|
|
zoomLevel = view.getZoom() + 1, |
|
48
|
|
|
resolution = view.getResolution(); |
|
49
|
|
|
this.beforeRender(ol.animation.zoom({ |
|
|
|
|
|
|
50
|
|
|
'resolution': resolution, |
|
51
|
|
|
'duration': 500 |
|
52
|
|
|
})); |
|
53
|
|
|
view.setZoom(zoomLevel); |
|
54
|
|
|
}; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Zooms out the map |
|
58
|
|
|
*/ |
|
59
|
|
|
ol.Map.prototype.zoomOut = function() { |
|
60
|
|
|
var view = this.getView(), |
|
61
|
|
|
zoomLevel = view.getZoom() - 1, |
|
62
|
|
|
resolution = view.getResolution(); |
|
63
|
|
|
this.beforeRender(ol.animation.zoom({ |
|
|
|
|
|
|
64
|
|
|
'resolution': resolution, |
|
65
|
|
|
'duration': 500 |
|
66
|
|
|
})); |
|
67
|
|
|
view.setZoom(zoomLevel); |
|
68
|
|
|
}; |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Zooms to given point |
|
72
|
|
|
* @param {Array.<number>} center |
|
73
|
|
|
* @param {number} zoomLevel |
|
74
|
|
|
* @param {number=} opt_duration |
|
75
|
|
|
*/ |
|
76
|
|
|
ol.Map.prototype.zoomTo = function(center, zoomLevel, opt_duration) { |
|
77
|
|
|
var view = this.getView(), |
|
78
|
|
|
resolution = view.getResolution(), |
|
79
|
|
|
duration = opt_duration !== undefined ? opt_duration : 500; |
|
80
|
|
|
this.beforeRender(ol.animation.zoom({ |
|
|
|
|
|
|
81
|
|
|
'resolution': resolution, |
|
82
|
|
|
'duration': duration |
|
83
|
|
|
})); |
|
84
|
|
|
view.setCenter(center); |
|
85
|
|
|
view.setZoom(zoomLevel); |
|
86
|
|
|
}; |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Rotate the map |
|
90
|
|
|
* @param {number} rotation |
|
91
|
|
|
*/ |
|
92
|
|
|
ol.Map.prototype.rotate = function(rotation) { |
|
93
|
|
|
var view = this.getView(), |
|
94
|
|
|
rotate = view.getRotation() + (rotation * Math.PI/180), |
|
95
|
|
|
center = view.getCenter(); |
|
96
|
|
|
|
|
97
|
|
|
this.beforeRender(ol.animation.rotate({ |
|
|
|
|
|
|
98
|
|
|
'rotation':view.getRotation(), |
|
99
|
|
|
'anchor':center, |
|
100
|
|
|
'duration':200 |
|
101
|
|
|
})); |
|
102
|
|
|
view.rotate(rotate, center); |
|
103
|
|
|
if (this.ov_view != null) { |
|
104
|
|
|
this.ov_view.rotate(rotate); |
|
105
|
|
|
} |
|
106
|
|
|
}; |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* Rotate the map in the left direction |
|
110
|
|
|
*/ |
|
111
|
|
|
ol.Map.prototype.rotateLeft = function() { |
|
112
|
|
|
this.rotate(-5); |
|
113
|
|
|
if (this.ov_view != null) { |
|
114
|
|
|
this.ov_view.rotate(-5); |
|
115
|
|
|
} |
|
116
|
|
|
}; |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* Rotate the map in the right direction |
|
120
|
|
|
*/ |
|
121
|
|
|
ol.Map.prototype.rotateRight = function() { |
|
|
|
|
|
|
122
|
|
|
this.rotate(5); |
|
123
|
|
|
if (this.ov_view != null) { |
|
124
|
|
|
this.ov_view.rotate(5); |
|
125
|
|
|
} |
|
126
|
|
|
}; |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* Resets the rotation of the map |
|
130
|
|
|
*/ |
|
131
|
|
|
ol.Map.prototype.resetRotation = function() { |
|
|
|
|
|
|
132
|
|
|
this.getView().rotate(0, this.getView().getCenter()); |
|
133
|
|
|
if (this.ov_view != null) { |
|
134
|
|
|
this.ov_view.rotate(0); |
|
135
|
|
|
} |
|
136
|
|
|
}; |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.